//
//  SYSoundTool.m
//  ARC与MRC状态下的单例分析
//
//  Created by zhouguodong on 15/4/4.
//  Copyright (c) 2015年 shuanyuan. All rights reserved.
//

#import "SYSoundTool.h"

@implementation SYSoundTool
// 保存唯一的实例
static id instance;

// 为实例对象仅开启一次内存空间
+ (instancetype)allocWithZone:(struct _NSZone *)zone
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [super allocWithZone:zone];
    });
    return instance;
}
// 提供对外的统一的访问接口,仅被初始化一次
+ (instancetype)sharedSoundTool
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
       instance =  [[self alloc]init];
    });
    return instance;
}

// copy操作创建的对象的唯一性
-(id)copyWithZone:(NSZone *)zone
{
    return instance;
}

#pragma MRC 状态下单例分析
- (oneway void)release
{
    
}
- (instancetype)autorelease
{
    return self;
}
- (instancetype)retain
{
    return self;
}
- (NSUInteger)retainCount
{
    return 1;
}

@end
